home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / beeper1.zip / BEEP45.ASM < prev    next >
Assembly Source File  |  1991-06-05  |  2KB  |  85 lines

  1. ; BEEP45.COM by Duane Paulson 06/05/91.
  2. ;  Beeps once a second for approx. 45 seconds or until a key is pressed.
  3. ;  Created using comtemp.asm template by Chuck Nelson; (c) NELSOFT Software.
  4. ;  All rights reserved. Used by permission.
  5. ;  Comtemp.asm is included in The PC Assembler Helper and Tutor by
  6. ;  Chuck Nelson, downloadable as "PCTUTOR.xxx".
  7.  
  8. COMSEG  SEGMENT  PUBLIC  'CODE'
  9.  
  10.     ASSUME    cs:COMSEG, ds:COMSEG, es:COMSEG, ss:COMSEG
  11.  
  12. ORG    100h
  13.  
  14. main    proc    NEAR
  15.  
  16. start:    mov     ax,0E07h    ; TTY output - ascii 7 (beep)
  17.     mov    bh,0        ; primary video page
  18.     int    10h        ; call bios
  19.  
  20. main_loop:
  21.     mov    ah,0        ; get system timer
  22.     int    01Ah        ; call bios
  23.  
  24.                 ; system timer returns a double word (32 bits).
  25.                 ; since we're only waiting for one second,
  26.                 ; looking at the low word will suffice.
  27.  
  28.     add    dx,18        ; add 18 to low word (timer ticks 18 times/sec)
  29.     mov    low_timer,dx    ; store low word
  30.  
  31. wayt:    mov    ah,0Bh        ; check for character waiting
  32.     int    21h        ; call dos
  33.  
  34.     cmp    al,0FFh        ; character waiting?
  35.     je    clear_buffer    ;  then exit
  36.  
  37.     mov    ah,0        ; get system timer
  38.     int    01Ah        ; call bios
  39.  
  40.     cmp    dx,low_timer    ; compare low word to low_timer
  41.     jb    wayt        ; loop for 1 second
  42.  
  43.     mov     ax,0E07h    ; TTY output - ascii 7 (beep)
  44.     mov    bh,0        ; primary video page
  45.     mov    cx,1        ; display 1 character
  46.     int    10h        ; call bios
  47.  
  48.     inc    count        ; check if 45 seconds has passed
  49.     cmp    count,40
  50.     jne    @F
  51.  
  52.     jmp    short    endit
  53.  
  54. @@:    mov    ah,0Bh        ; check for character waiting
  55.     int    21h        ; call dos
  56.  
  57.     cmp    al,0        ; no keypress?
  58.     je    main_loop    ;  then loop
  59.     
  60. clear_buffer:
  61.     mov    ah,7        ; Character input without echo
  62.     int    21h        ; call dos
  63.  
  64. endit:    mov    ah,0Bh        ; check for character waiting
  65.     int    21h        ; call dos
  66.  
  67.     cmp    al,0FFh        ; character waiting?
  68.     je    clear_buffer    ;  then loop
  69.  
  70.     mov    ax,4C00h    ; exit with 0 exit code
  71.     int    21h        ; call dos and exit
  72.  
  73.     ret
  74.  
  75. main    endp
  76.  
  77. low_timer    dw    ?
  78. count        db    0
  79.  
  80. COMSEG    ENDS
  81.  
  82. END    start
  83.  
  84.  
  85.